package com.xb.controller;

import com.xb.entity.User;
import com.xb.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class Controller {

    @Autowired
    UserService userService;

    @GetMapping("getUser")
    public User getUser(Integer id) {
        return userService.getUserById(id);
    }

    @PostMapping("addUser")
    public void addUser(User user) {
        userService.addUser(user);
    }

    @PostMapping("updateUser")
    public void updateUser(User user) {
        userService.updateUser(user);
    }

    @PostMapping("delUser")
    public void delUser(Integer id) {
        userService.delUser(id);
    }

}